package cn.cycleif.admin.controller;

import cn.cycleif.admin.pojo.dto.AssignRoleMenuDTO;
import cn.cycleif.admin.service.AdminMenuService;
import cn.cycleif.entity.Menu;
import cn.cycleif.util.R;
import cn.dev33.satoken.annotation.SaCheckRole;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Date: 25/2/6-17:18
 * @Desc:
 */
@RestController
@RequestMapping("/sys/permission")
@Tag(name = "权限管理", description = "权限管理接口")
@SaCheckRole("admin")
public class AdminMenuController {

  @Autowired
  private AdminMenuService adminMenuService;

  @PostMapping()
  @Operation(summary = "添加权限")
  public R<String> add(@RequestBody Menu menu) {
    return adminMenuService.add(menu);
  }

  @PostMapping("/assign")
  @Operation(summary = "给角色分配权限")
  public R<String> assign(@RequestBody AssignRoleMenuDTO dto) {
    return adminMenuService.assign(dto);
  }
}
